package main

import "fmt"

type Teacher struct {
	Name   string
	Age    int
	School string
}

func main() {
	//initStruct()
	intiStructByPoint()
}

func initStruct() {
	// 方式1
	teacher := Teacher{"张三", 11, "大连理工"}
	fmt.Println("方式1: ", teacher)

	// 方式2
	var teacher2 Teacher
	teacher2.Name = "李四"
	teacher2.Age = 22
	teacher2.School = "东财"
	fmt.Println("方式2：", teacher2)
}

func intiStructByPoint() {
	// 方式3 ， 其实这个teacher3是一个指针
	var teacher3 = new(Teacher)
	teacher3.Name = "王五"
	teacher3.Age = 22
	teacher3.School = "家里蹲大学"
	fmt.Println("方式3：", teacher3)  // 输出指针
	fmt.Println("方式3：", *teacher3) // 输出指针中的值

	// 方式4 ， 其实这个teacher4是一个指针
	var teacher4 = &Teacher{"t5", 22, "清华大学"}
	fmt.Println("方式4：", teacher4)
	fmt.Println("方式4：", *teacher4)
}
